/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view.panels;

import java.awt.Graphics;
import model.ChessPiece1;
import utility.ImageToolbox;

/**
 *
 * @author Jeppe
 */
public class ChessPiecePanel extends javax.swing.JPanel {

    private ChessPiece1 chessPiece;

    /**
     * Creates new form ChessPiecePanel
     */
    public ChessPiecePanel(ChessPiece1 chesspiece) {
        initComponents();
        this.chessPiece = chesspiece;
        jLabel1.repaint();
	setSize(51, 51);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel(){
            public void paint(Graphics g){
                ImageToolbox.drawImage(g, chessPiece.getImageIcon(), 0, 0, jLabel1.getWidth(), jLabel1.getHeight());
            }
        };

        setOpaque(false);
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                formMouseReleased(evt);
            }
        });
        setLayout(null);
        add(jLabel1);
        jLabel1.setBounds(0, 0, 50, 50);
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
        System.out.println(chessPiece.getColor());
    }//GEN-LAST:event_formMouseReleased


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
